unit OrderValidatorInterceptor;

interface

uses Winapi.Windows, System.Classes, System.SysUtils, System.Rtti, Spring.XE.Interceptor;

type

  TOrderValidatorInterceptor = class(TSpringInterceptor)
  protected
    procedure InterceptBeforeNotify(Instance: TObject;
      Method: TRttiMethod; const Args: TArray<TValue>; out DoInvoke: Boolean;
      out Result: TValue); override;
    procedure InterceptAfterNotify(Instance: TObject;
      Method: TRttiMethod; const Args: TArray<TValue>; var Result: TValue); override;
    procedure InterceptExceptionNotify(Instance: TObject;
      Method: TRttiMethod; const Args: TArray<TValue>; out RaiseException: Boolean;
      TheException: Exception; out Result: TValue); override;
  end;

implementation

{ TOrderValidatorInterceptor }

uses Spring.XE.Utils;

procedure TOrderValidatorInterceptor.InterceptAfterNotify(Instance: TObject; Method: TRttiMethod;
  const Args: TArray<TValue>; var Result: TValue);
begin
  inherited;
  Writeln('TOrderValidatorInterceptor.InterceptAfterNotify After:' + Method.Name);
end;

procedure TOrderValidatorInterceptor.InterceptBeforeNotify(Instance: TObject; Method: TRttiMethod;
  const Args: TArray<TValue>; out DoInvoke: Boolean; out Result: TValue);
begin
  inherited;
  Writeln('TOrderValidatorInterceptor.InterceptAfterNotify Befor:' + Method.Name);
end;

procedure TOrderValidatorInterceptor.InterceptExceptionNotify(Instance: TObject;
  Method: TRttiMethod; const Args: TArray<TValue>; out RaiseException: Boolean;
  TheException: Exception; out Result: TValue);
begin
  inherited;

end;

initialization
  TSpringXEUtils.TryRegisterClass(TOrderValidatorInterceptor);

end.
